Skip to content

Simplify internals of {Rc,Arc}::default#152591

Open
alexcrichton wants to merge 1 commit intorust-lang:mainfrom
alexcrichton:simplify-rc-arc-default
Open

Simplify internals of {Rc,Arc}::default#152591
alexcrichton wants to merge 1 commit intorust-lang:mainfrom
alexcrichton:simplify-rc-arc-default

Conversation

@alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Feb 13, 2026

This commit simplifies the internal implementation of Default for these two pointer types to have the same performance characteristics as before (a side effect of changes in #131460) while avoid use of internal private APIs of Rc/Arc. To preserve the same codegen as before some non-generic functions needed to be tagged as #[inline] as well, but otherwise the same IR is produced before/after this change.

The motivation of this commit is I was studying up on the state of initialization of Arc and Rc and figured it'd be nicer to reduce the use of internal APIs and instead use public stable APIs where possible, even in the implementation itself.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 13, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 13, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, joboet

@rust-log-analyzer

This comment has been minimized.

This commit simplifies the internal implementation of `Default` for
these two pointer types to have the same performance characteristics as
before (a side effect of changes in 131460) while avoid use of internal
private APIs of Rc/Arc. To preserve the same codegen as before some
non-generic functions needed to be tagged as `#[inline]` as well, but
otherwise the same IR is produced before/after this change.

The motivation of this commit is I was studying up on the state of
initialization of `Arc` and `Rc` and figured it'd be nicer to reduce the
use of internal APIs and instead use public stable APIs where possible,
even in the implementation itself.
@alexcrichton alexcrichton force-pushed the simplify-rc-arc-default branch from da1ddcf to ba5ff3d Compare February 14, 2026 00:36
@@ -30,8 +31,7 @@ pub fn new_uninit(x: u64) -> Arc<[u64; 1000]> {
// CHECK-LABEL: @new_uninit_slice
#[no_mangle]
pub fn new_uninit_slice(x: u64) -> Arc<[u64]> {
// CHECK: call alloc::sync::arcinner_layout_for_value_layout
// CHECK-NOT: call alloc::sync::arcinner_layout_for_value_layout
// CHECK-NOT: %[[B:.+]] = alloca
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The breadcrumbs for this codegen test points back at #111634 which had to do with internal refactorings about how methods were done. I don't believe that these codegen tests are really all that applicable any more so I did my best to at least keep them somewhat, but the extra #[inline] in this PR effectively means that the internals this test relies on also changed which means that the test needed an update one way or another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants